<template>
	<view class="user_box">

		<!-- 自定义导航栏 -->
		<view>
			<!-- 2.0.19支持autoBack，默认为false -->
			<u-navbar title="我的" @rightClick="rightClick" :autoBack="true" :placeholder="true">
			</u-navbar>
		</view>
		<!-- head区域 -->
		<view class="head_user">
			<block v-if="isShow">
				<view class="head_user_info">
					<image :src="userinfo.avatarurl"></image>
					<view class="head_user_info_name" hover-class="touchOpacity">
						<text>{{userinfo.nickname}}</text>
						<text @click="goUserinfo">完善资料让小U更懂你</text>
					</view>
					<view class="head_user_info_sign" hover-class="touchOpacity" @click="goSign">
						<image src="../../static/images/红包.png"></image>
						<text>每日签到</text>
					</view>
				</view>
			</block>
			<view class="btn" v-else>
				<button @click="goLogin" size="mini">登录/注册</button>
			</view>


			<view class="head_usert_menu">
				<view class="head_usert_menu_row" hover-class="touchOpacity" v-for="(item,index) in menuList"
					:key="index">
					<text>{{item.number}}</text>
					<text>{{item.name}}</text>
				</view>
			</view>
			<view class="head_user_order">
				<view class="head_user_order_top" hover-class="touchOpacity" @click="goOrder(3)">
					<text>我的订单</text>
					<text>全部订单 > </text>
				</view>
				<view class="head_user_order_bottom">
					<view class="head_user_order_bottom_row" hover-class="touchOpacity" v-for="(item,index) in orders"
						:key="index" @click="goOrder(index)">
						<image :src="item.src"></image>
						<text>{{item.name}}</text>
					</view>
				</view>
			</view>
		</view>
		<!-- 功能菜单区域 -->
		<view class="resDetail">
			<view hover-class="touchOpacity" @click="goAddress">
				<label for="" class="resDetail_title">
					<image src="../../static/images/address.png"></image>
					地址管理
				</label>
				<label for="" style="margin-right:40rpx;color:#333333;font-size: 24rpx;"> ></label>
			</view>
			<view class="" hover-class="touchOpacity">
				<label for="" class="resDetail_title">
					<image src="../../static/images/wallet.png"></image>
					我的钱包
				</label>
				<label for="" style="margin-right:40rpx;color:#666666;font-size: 24rpx;">剩余200U币 ></label>
			</view>
			<view class="" hover-class="touchOpacity" @click="goCode">
				<label for="" class="resDetail_title">
					<image src="../../static/images/QR_code.png"></image>
					我的二维码
				</label>
				<label for="" style="margin-right:40rpx;color:#666666;font-size: 24rpx;"> ></label>
			</view>
			<view class="" hover-class="touchOpacity">
				<label for="" class="resDetail_title">
					<image src="../../static/images/partner.png"></image>
					我的小伙伴
				</label>
				<label for="" style="margin-right:40rpx;color:#666666;font-size: 24rpx;"> ></label>
			</view>
			<view class="" hover-class="touchOpacity">
				<label for="" class="resDetail_title">
					<image src="../../static/images/free.png"></image>
					0元试用
				</label>
				<label for="" style="margin-right:40rpx;color:#666666;font-size: 24rpx;"> ></label>
			</view>
		</view>
	</view>
</template>

<script>
	// import isLogin from '../../utils/isLogin';
	export default {
		async onShow() {
			let res = await this.$isLogin(this);
			// console.log(res);
			if (res) {
				this.isShow = res
				this.userinfo = uni.getStorageSync('userInfo')
				this.userinfo.avatarurl = this.$baseUrl + this.userinfo.avatarurl
				// console.log(this.userinfo.avatarurl);
			} else {
				this.isShow = res
			}
		},
		data() {
			return {
				isShow: false,
				userinfo: {
					avatarurl: '',
					nickname: '请登录'
				}, //初始化用户信息
				menuList: [{
						name: '我的收藏',
						number: 12
					},
					{
						name: '浏览记录',
						number: 12
					},
					{
						name: '我的红包',
						number: '￥0'
					},
					{
						name: '优惠券',
						number: 12
					}
				],
				orders: [{
						src: '../../static/images/1.png',
						name: '代付款'
					},
					{
						src: '../../static/images/2.png',
						name: '代发货'
					},
					{
						src: '../../static/images/3.png',
						name: '待收货'
					},
					{
						src: '../../static/images/4.png',
						name: '全部订单'
					}
				]
			}
		},
		methods: {
			// // 跳转到签到页面（测试页面）
			// goSign(){
			// 	uni.navigateTo({
			// 		url:'../sign/sign'
			// 	})
			// },
			// // 跳转到我的二维码页（测试页面）
			// goCode(){
			// 	uni.navigateTo({
			// 		url:'../mycode/mycode'
			// 	})
			// },
			// 跳转到登录页面
			goLogin() {
				uni.navigateTo({
					url: '../login/login'
				})
			},
			// 跳转到订单页面
			goOrder(index) {

				uni.navigateTo({
					url: '../orderlist/orderlist?status=' + index
				})

			},
			// // 跳转到地址页面
			// goAddress(){
			// 	uni.navigateTo({
			// 		url:'../address/address'
			// 	})
			// }
			// 跳转修改用户信息页面
			goUserinfo() {
				uni.navigateTo({
					url: '../userinfo/userinfo'
				})
			},
		}
	}
</script>

<style>
	/* 引入样式 */
	@import url("@/static/css/mine.css");
</style>